package com.hangxiang.approval.controller;

import com.hangxiang.approval.common.IntegerCommon;
import com.hangxiang.approval.common.ResultBean;
import com.hangxiang.approval.common.UserManagerInsertCommon;
import com.hangxiang.approval.common.UserManagerUpdateCommon;
import com.hangxiang.approval.service.UserManagerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (UserManager)表控制层
 *
 * @author makejava
 * @since 2020-12-04 13:53:37
 */
@RestController
@RequestMapping("userManager")
@Api(tags = "UserManager相关功能")
public class UserManagerController {
    /**
     * 服务对象
     */
    @Resource
    private UserManagerService userManagerService;

    /**
     * 通过主键查询单条数据
     *
     * @param common 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    @ApiOperation(value = "通过主键查询单条数据")
    @ResponseBody
    public ResultBean selectOne(@RequestBody @Validated IntegerCommon common) {
        return ResultBean.success(userManagerService.queryById(common));
    }

    /**
     * 新增数据
     *
     * @param userManagerInsertCommon 实例对象
     * @return 实例对象
     */
    @PostMapping("insertUserManager")
    @ApiOperation(value = "添加数据")
    @ResponseBody
    public ResultBean insertUserManager(@RequestBody @Validated UserManagerInsertCommon userManagerInsertCommon) {
        return ResultBean.success(userManagerService.insertUserManager(userManagerInsertCommon));
    }

    /**
     * 新增数据
     *
     * @param userManagerUpdateCommon 实例对象
     * @return 实例对象
     */
    @PostMapping("updateUserManager")
    @ApiOperation(value = "修改数据")
    @ResponseBody
    public ResultBean updateUserManager(@RequestBody @Validated UserManagerUpdateCommon userManagerUpdateCommon) {
        return ResultBean.success(userManagerService.updateUserManager(userManagerUpdateCommon));
    }


}